package com.wang.controller;

import com.aaa.security.util.WebUtils;
import com.aaa.util.JwtUtil;
import com.aaa.vo.Result;
import com.wang.service.BBusinessInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("collect")
public class CollectController {
    @Autowired
    private BBusinessInfoService bBusinessInfoService;
    @RequestMapping("/findCollectByphone")
    public Result findCollectByphone(){
        String token = WebUtils.getRequest().getHeader("token");
        Map<String, Object> tokenChaim = JwtUtil.getTokenChaim(token);
        String username = (String) tokenChaim.get("username");
        return bBusinessInfoService.findCollectByphone(username);
    }
    @RequestMapping("/unfollow")
    public Result unfollow(Integer bid) {
        String token = WebUtils.getRequest().getHeader("token");
        Map<String, Object> tokenChaim = JwtUtil.getTokenChaim(token);
        String username = (String) tokenChaim.get("username");
        return bBusinessInfoService.unfollow(String.valueOf(bid), username);
    }
    @RequestMapping("/CollectibleGoods")
    public Result CollectibleGoods(){
        String token = WebUtils.getRequest().getHeader("token");
        Map<String, Object> tokenChaim = JwtUtil.getTokenChaim(token);
        String username = (String) tokenChaim.get("username");
        return bBusinessInfoService.CollectibleGoods(username);
    }
    @RequestMapping("unfollowCollectibleGoods")
    public Result unfollowCollectibleGoods(String goodsid) {
        String token = WebUtils.getRequest().getHeader("token");
        Map<String, Object> tokenChaim = JwtUtil.getTokenChaim(token);
        String username = (String) tokenChaim.get("username");
        Result result = bBusinessInfoService.unfollowCollectibleGoods(goodsid, username);
        return result;
    }

}
